

package com.etd.workflow.domin;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.etd.base.config.ConstSysParam;
import com.etd.base.domain.impl.BaseDomain;
import com.etd.base.domain.inf.BaseDomainInf;
/**
 * 流程节点人员、角色及字段必填配置
 * @author jacksonWang
 *
 */
@Entity
@Table(name=ConstSysParam.MODULE_FLOW_TASK_CONFIG)
public class FlowTaskConfig extends BaseDomain implements BaseDomainInf,Comparable<FlowTaskConfig>{
	
	
	/*
	 * 主键
	 */
	@Id
	@Column
	@GeneratedValue(strategy=GenerationType.TABLE,generator="flowTaskConfigGenerator")
	@TableGenerator(name="flowTaskConfigGenerator",
					table="sysman_generation_key",
					pkColumnValue=ConstSysParam.MODULE_FLOW_TASK_CONFIG,
					pkColumnName="primary_key",
					valueColumnName="key_value")
	private Long id;
	
	/*
	 * 流程定义编码
	 */
	private String procDefinitionId;
	/*
	 * 流程定义名称
	 */
	private String procDefinitionName;
	
	
	/*
	 * 流程节点id
	 */
	private String activityId;	

	/*
	 * 节点类型1:启动节点,0:普通节点,-1:结束节点
	 */
	@Column(length=2)
	private Long activityType;
	/*
	 * 流程节点名称
	 */
	private String activityName;
	
	/*
	 * json字符串格式流程配置
	 * groups:节点组设置,users:节点用户设置,field:必填字段设置
	 * sample:groups:'1,2',users:'1,2',field:'name,reason'
	 */
	@Column(length=500)
	private String activityConfig;
	
	
	private String bizname;
	private String fullBizcode;
	
	/*
	 * 流程配置记录同步状态,
	 * 0:流程文件定义节点与当前模块配置节点匹配
	 * 1:流程文件中有节点定义，当前模块中无节点配置
	 * -1:流程文件中无节点配置，当前模块中有节点定义
	 */
	@Transient
	private Integer state = -1;
	
	/*
	 * 业务名称，多个业务共用用流程时用于区别不同流程角色定义
	 */
	

	public String getProcDefinitionName() {
		return procDefinitionName;		
	}

	public void setProcDefinitionName(String procDefinitionName) {
		this.procDefinitionName = procDefinitionName;
	}

	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	public String getActivityConfig() {
		return activityConfig;
	}

	public void setActivityConfig(String activityConfig) {
		this.activityConfig = activityConfig;
	}
	
	
	@Override
	public Long getId() {
		// TODO Auto-generated method stub
		return this.id;
	}


	@Override
	public void setId(Long id) {
		// TODO Auto-generated method stub
		this.id = id;
	}
	
	public String getActivityId() {
		return activityId;
	}

	public void setActivityId(String activityId) {
		this.activityId = activityId;
	}

	/**
	 * 流程配置记录同步状态,
	 * 0:流程文件定义节点与当前模块配置节点匹配
	 * 1:流程文件中有节点定义，当前模块中无节点配置
	 * -1:流程文件中无节点配置，当前模块中有节点定义
	 */
	public Integer getState() {
		return state;
	}

	/**
	 * * 流程配置记录同步状态,
	 * 0:流程文件定义节点与当前模块配置节点匹配
	 * 1:流程文件中有节点定义，当前模块中无节点配置
	 * -1:流程文件中无节点配置，当前模块中有节点定义
	 * @param state	状态值
	 */
	public void setState(Integer state) {
		this.state = state;
	}

	public String getProcDefinitionId() {
		return procDefinitionId;
	}

	public void setProcDefinitionId(String procDefinitionId) {
		this.procDefinitionId = procDefinitionId;
	}
	
	public FlowTaskConfig(){}
	
	public FlowTaskConfig(String procDefinitionId,String activityId,String activityName,Integer state){
		this.procDefinitionId = procDefinitionId;
		this.activityId = activityId;
		this.activityName = activityName;
		this.state = state;
	}
	
	public FlowTaskConfig(String procDefinitionId,
			String activityId,
			String activityName,
			String fullBizcode,
			String bizname,
			Integer state){
		this.procDefinitionId = procDefinitionId;
		this.activityId = activityId;
		this.activityName = activityName;
		this.fullBizcode = fullBizcode;
		this.bizname = bizname;
		this.state = state;
	}

	public String getFullBizcode() {
		return fullBizcode;
	}

	public void setFullBizcode(String fullBizcode) {
		this.fullBizcode = fullBizcode;
	}

	public String getBizname() {
		return bizname;
	}

	public void setBizname(String bizname) {
		this.bizname = bizname;
	}
	
	public int compareTo(FlowTaskConfig o){
		if(o.sortedid==null)
			return 1;
		
		if(this.sortedid==null)
			return -1;
					
		if(this.sortedid > o.sortedid){
			return 1;
		}else{
			return -1;
		}
	}

	public Long getActivityType() {
		return activityType;
	}

	public void setActivityType(Long activityType) {
		this.activityType = activityType;
	}

	

	
}
